﻿using System.Collections.Generic;
using UnityEngine;

public class PathPoint
{
    private static long idSeed = 10000;
    public static readonly Stack<PathPoint> Pool = new();
    public static void Push(PathPoint point)
    {
        if (point == null)
        {
            return;
        }

        Pool.Push(point);

        point.Clear();
    }
    public static PathPoint Pop()
    {
        PathPoint item;
        if (Pool.Count > 0)
        {
            item = Pool.Pop();
        }
        else
        {
            item = new PathPoint();
        }
        item.Id = idSeed++;
        return item;
    }

    public long Id { get; private set; }

    public Vector3 Value;

    public ObstacleBlock Block;

    public PathPoint DiagonalPoint;

    public bool Disable;

    private void Clear()
    {
        Id = 0;
        Value = Vector3.zero;
        Block = null;
        DiagonalPoint = null;
        Disable = false;
    }
}
